﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Micua.iChat.Models;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234235 上有介绍

namespace Micua.iChat.Controls
{
    public sealed class MessageBoxListView : ListView
    {
        public MessageBoxListView()
        {
            this.DefaultStyleKey = typeof(MessageBoxListView);
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
        }
    }
    public class MessageBoxListViewItemTemplateSelector : DataTemplateSelector
    {
        public MessageBoxListViewItemTemplateSelector()
        {

        }
        public DataTemplate LeftItemTemplate { get; set; }
        public DataTemplate RightItemTemplate { get; set; }
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            var msg = item as Message;
            if (msg != null)
            {
                if (msg.FromId == 10001)
                {
                    return RightItemTemplate;
                }
                return LeftItemTemplate;
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}
